package component.fulltextsearch.index;

import java.io.Reader;

import org.apache.lucene.analysis.CharTokenizer;

/**
 * 分词器
 * 通过指定字符分词
 *
 */
public class StopCharTokenizer extends CharTokenizer {
	private final char[] stopChars;

	/** Construct a new WhitespaceTokenizer. */
	public StopCharTokenizer(Reader in, char[] stopChars) {
		super(in);
		this.stopChars = stopChars;
	}

	/** Collects only characters which do not satisfy
	 * {@link Character#isWhitespace(char)}.*/
	protected boolean isTokenChar(char c) {
		if (Character.isWhitespace(c)) {
			return false;
		}
		for (int i = 0; i < stopChars.length; i++) {
			if (c == stopChars[i]) {
				return false;
			}
		}
		return true;
	}
}